<template>
  <div class="login-container">
    <div class="login">
      <div class="logo">
        <img src="../assets/logo-temp.png" alt="logo">
      </div>
      <div class="tips">
        <div class="tips-main">
          <h1>登录</h1>
          <div>登录您的点子账号</div>
        </div>
      </div>
      <div class="main">
        <form action="">
          <div class="acount">
            <input :class="acountInputClass" v-model="acount" ref="acount" type="text" @focus="acountF" @blur="acountB">
            <div :class="acountClass">账号</div>
          </div>
          <div class="password">
            <input :class="passwordInputClass" v-model="password" ref="password" type="password" @focus="passwordF"
                   @blur="passwordB">
            <div :class="passwordClass">密码</div>
          </div>
        </form>
        <div class="check" v-if="check">请输入正确的账号和密码</div>
      </div>
      <div class="btns">
        <router-link to="register">
          <div class="register">
            <span>创建账号</span>
          </div>
        </router-link>
        <router-link to="/index">
          <div class="login-btn" @click="userInformation">
            <span>登录</span>
          </div>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
import eventBus from '../components/eventBus'
export default {
  name: 'Login',
  data () {
    return {
      acountClass: 'place-acount',
      passwordClass: 'place-password',
      acountInputClass: 'acount-input',
      passwordInputClass: 'password-input',
      acount: '',
      password: '',
      check: false
    }
  },
  methods: {
    acountF () {
      this.acountClass = 'place-acount-hover'
      this.acountInputClass = 'acount-input-hover'
    },
    acountB () {
      if (this.acount === '') {
        this.acountClass = 'place-acount'
      } else {
        this.acountClass = 'place-acount-hover'
      }
      this.acountInputClass = 'acount-input'
    },
    passwordF () {
      this.passwordClass = 'place-password-hover'
      this.passwordInputClass = 'password-input-hover'
    },
    passwordB () {
      if (this.password === '') {
        this.passwordClass = 'place-password'
      } else {
        this.passwordClass = 'place-password-hover'
      }
      this.passwordInputClass = 'password-input'
    },
    userInformation () {
      if (this.acount === '' && this.password === '') {
        this.check = true
      } else {
        eventBus.$emit('userInformation', {
          acount: this.acount,
          pwd: this.password
        })
      }
    }
  }
}
</script>

<style scoped>
.check {
  color: #c70000;
  padding-left: 115px;
}
.login-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.login {
  width: 646px;
  height: 542px;
  padding: 48px 30px 4px;
  box-sizing: border-box;
  border: 1px solid #f6815b;
  border-radius: 10px;
  background-color: #fed71a;
  opacity: .9;
  z-index: 2;
  display: flex;
  /*justify-content: center;*/
  /*align-items: center;*/
  flex-direction: column;
  position: relative;
}

.logo {
  height: 89px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.tips {
  height: 80px;
  display: flex;
  justify-content: center;
}

.tips h1 {
  color: #202124;
  padding-bottom: 0;
  padding-top: 16px;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.3333;
  margin-bottom: 0;
  margin-top: 0;
  text-align: center;
}

.main {
  margin-top: 20px;
  position: relative;
  color: #000000;
}

.acount-input {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 336px;
  margin: 1px 1px 10px 1px;
  padding: 13px 15px;
  outline: none;
  border: 1px solid #2c2c2c;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.acount-input-hover {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 336px;
  margin: 1px 1px 10px 1px;
  padding: 13px 15px;
  outline: none;
  border: 2px solid blue;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.password-input {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 336px;
  margin: 1px 1px 10px 1px;
  padding: 13px 15px;
  outline: none;
  border: 1px solid #2c2c2c;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.password-input-hover {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 336px;
  margin: 1px 1px 10px 1px;
  padding: 13px 15px;
  outline: none;
  border: 2px solid blue;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.acount {
  display: flex;
  justify-content: center;
}

.password {
  display: flex;
  justify-content: center;
}

.place-acount {
  font-size: 20px;
  font-weight: 400;
  position: absolute;
  top: 23px;
  left: 125px;
  color: #000;
  transition: all .3s;
  background-color: transparent;
  z-index: 1;
}

.place-acount-hover {
  font-size: 12px;
  font-weight: 400;
  position: absolute;
  top: -7px;
  left: 125px;
  color: #000;
  transition: all .3s;
  background-color: #fed71a;
  z-index: 2;
}

.place-password {
  font-size: 20px;
  font-weight: 400;
  position: absolute;
  top: 107px;
  left: 125px;
  color: #000;
  transition: all .3s;
  background-color: transparent;
  z-index: 1;
}

.place-password-hover {
  font-size: 12px;
  font-weight: 400;
  position: absolute;
  top: 78px;
  left: 125px;
  color: #000;
  transition: all .3s;
  background-color: #fed71a;
  z-index: 2;
}

.btns {
  width: 55%;
  display: flex;
  justify-content: space-between;
  margin-left: 120px;
  margin-top: 30px;
  position: absolute;
  bottom: 60px;
}

.register {
  width: 72px;
  height: 36px;
  cursor: pointer;
  line-height: 36px;
  border-radius: 4px;
  transition: all .3s;
}

.register:hover {
  background-color: #e7ca3a;
}

.register:hover span {
  color: #287ae7;
}

.register:active {
  background-color: #c5ad32;
}

.register:active span {
  color: #236bcb;
}

.register span {
  color: #317fe7;
  display: block;
  align-items: center;
  transition: all .3s;
}

.login-btn {
  width: 90px;
  height: 40px;
  line-height: 40px;
  background-color: #1a73e8;
  border-radius: 4px;
  cursor: pointer;
  transition: all .3s;
}

.login-btn span {
  display: block;
  text-align: center;
  color: #ffffff;
  transition: all .3s;
}

.login-btn:hover {
  background-color: #1969d7;
}

.login-btn:hover span {
  color: #eaeaea;
}

.login-btn:active {
  background-color: #1257b0;
}

.login-btn:active span {
  color: #dcdcdc;
}
</style>
